/* nbd-queue.h */

#ifndef NBD_QUEUE_H_FILE
#define NBD_QUEUE_H_FILE

#define NBD_QUEUE_LEN 16

typedef struct NBD_REQ {
  unsigned long long handle;
  unsigned long long off;
  unsigned int len;
} NBD_REQ;

typedef struct NBD_QUEUE {
  int first;
  int last;
  NBD_REQ items[NBD_QUEUE_LEN];
} NBD_QUEUE;

void nbd_queue_init(NBD_QUEUE *q);
int nbd_queue_has_item(NBD_QUEUE *q);
int nbd_queue_can_add(NBD_QUEUE *q);
int nbd_queue_get_item(NBD_QUEUE *q, NBD_REQ *item);
int nbd_queue_add_item(NBD_QUEUE *q, NBD_REQ *item);

#endif /* NBD_QUEUE_H_FILE */
